package cn.com.bluemoon.daps.sync.config;

import cn.com.bluemoon.daps.common.toolkit.valueobject.PtSsh;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * ptserver配置信息
 *
 * @author Jarod.Kong
 * @date 2020/8/25 9:32
 */
@Configuration
@ConfigurationProperties(prefix = "daps.pt-server", ignoreUnknownFields = true)
@Slf4j
public class PtServerConfig {
    private String host;

    private String port;

    private String username;

    private String password;

    private String ptoscPath;

    public PtSsh getPtSsh() {
        PtSsh ptSsh = new PtSsh();
        ptSsh.setHost(getHost());
        ptSsh.setUsername(getUsername());
        ptSsh.setPassword(getPassword());
        ptSsh.setPort(getPort());
        return ptSsh;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPtoscPath() {
        if (ptoscPath == null) {
            ptoscPath = "/usr/local/percona-toolkit-3.3.0/bin/pt-online-schema-change";
        }
        return ptoscPath;
    }

    public void setPtoscPath(String ptoscPath) {
        this.ptoscPath = ptoscPath;
    }

}
